package pt.utl.ist.isr.livetrack.server.impl;

import pt.utl.ist.isr.livetrack.server.interfaces.Zone;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class ZoneImpl implements Zone {

    private static final Logger logger = Logger.getLogger(ZoneImpl.class);
    private String id;
    private String name;
    private Set<String> connections = new HashSet<String>();
    private boolean entryZone;
    private boolean exitZone;

    /**
     * Implemented just for using XMLEncoder/XMLDecoder.
     */
    @Deprecated
    public ZoneImpl() {
    }

    public ZoneImpl(String id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String getId() {
        return id;
    }

    public void setConnections(Set<String> connections) {
        this.connections = connections;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public Set<String> getConnections() {
        return connections;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean isEntryZone() {
        return entryZone;
    }

    @Override
    public void setEntryZone(boolean entryZone) {
        this.entryZone = entryZone;
    }

    @Override
    public boolean isExitZone() {
        return exitZone;
    }

    @Override
    public void setExitZone(boolean exitZone) {
        this.exitZone = exitZone;
    }

    @Override
    public String toString() {
        return "zone " + name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ZoneImpl other = (ZoneImpl) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 13 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
}
